local UIBase = require("view.UIBase")
local PopupFightAttrDebug = class("PopupFightAttrDebug", UIBase)
local attribute = require("config.attribute")

function PopupFightAttrDebug:ctor(entity)
    self._entity = entity
    local resource = {
        path = "Prefabs/Popup",
        name = "PopupFightAttrDebug",
        canvas = 3
    }
    PopupFightAttrDebug.super.ctor(self, resource)
end

function PopupFightAttrDebug:start()
    self._panelTouch:SetCallback(handler(self, self._onPanelTouchClick))
    self._listView:SetTemplate(
        handler(self, self._onItemUpdate),
        handler(self, self._onValueChange),
        handler(self, self._onItemTouch)
    )
    local len = attribute.length()
    self._listView:ReSize(len)
end

function PopupFightAttrDebug:_onItemUpdate(item, index)
    local startIndex = index + 1
    local cfg = attribute.indexOf(startIndex)
    item:updateUI(self._entity, cfg)
end

function PopupFightAttrDebug:_onValueChange()
end

function PopupFightAttrDebug:_onItemTouch()
end

function PopupFightAttrDebug:_onPanelTouchClick(event)
    if event == 3 then
        self:close()
    end
end

return PopupFightAttrDebug
